package com.ts.api.module.match.market.internal.wrapper.context;

import com.ts.api.module.api.convert.core.annotation.ApiConsumerMarketConvertType;
import com.ts.api.module.match.core.MatchRegisterContext;
import com.ts.api.module.match.market.internal.wrapper.MarketFederatePhoneWrapper;
import com.ts.api.module.match.market.internal.wrapper.MarketFederateUserFormWrapper;
import com.ts.api.module.match.market.internal.wrapper.MarketFederateWrapper;
import org.springframework.stereotype.Component;

/**
 *  贷超-联登包装器上下文
 *
 *  @author Pan
 */
@Component
public class MarketFederateWrapperContext extends MatchRegisterContext<ApiConsumerMarketConvertType, MarketFederateWrapper> {

    /**
     *  初始化构造函数
     *  @author Pan
     */
    public MarketFederateWrapperContext() {
        super(ApiConsumerMarketConvertType.class);
        register(ApiConsumerMarketConvertType.FEDERATE_PHONE,          MarketFederatePhoneWrapper.class);
        register(ApiConsumerMarketConvertType.FEDERATE_USER_FORM,      MarketFederateUserFormWrapper.class);
    }

    @Override
    public MarketFederateWrapper getContext(ApiConsumerMarketConvertType e) {
        return super.getContext(e);
    }

    /**
     *  通过贷超联登类型获取wrapper
     *
     *  @author Pan
     *  @param  apiFederateType     联登类型
     *  @return MarketFederateWrapperContext
     */
    public MarketFederateWrapper getContext(Integer apiFederateType) {
        ApiConsumerMarketConvertType apiConsumerMarketConvertType = ApiConsumerMarketConvertType.getFederateEnum(apiFederateType);
        return getContext(apiConsumerMarketConvertType);
    }
}
